package com.david.client;

import java.util.HashMap;
import java.util.Map;

import com.david.client.ui.LoginPanel;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.gwtext.client.widgets.LayoutDialog;
import com.gwtext.client.widgets.QuickTips;
import com.gwtext.client.widgets.form.Field;

public class ERP implements EntryPoint {

	private static PopupPanel messagePanel = new PopupPanel(true);
	static final RootPanel rootPanel = RootPanel.get();
	private static Widget currWidget = null;
	private Map screens = new HashMap();

	public void onModuleLoad() {

		Field.setMsgTarget("side");
		QuickTips.init();
		currWidget =(new LoginPanel()).getViewPanel(); 
		((LayoutDialog)currWidget).show();
		
//		RoundCornerBox box = new RoundCornerBox();
//		box.setTitle("New User");
//		box.setContent(new NewUserForm());
////		DeleteUserForm box = new DeleteUserForm();
//		rootPanel.add(box);
	}
	
	public static void replace(Widget newWidget ){
		
		if(currWidget != null){
			rootPanel.remove(currWidget);
		}
		rootPanel.add(newWidget);
		currWidget = newWidget;
	}
	
    public static void showMessage(String title, String message) {
        messagePanel.setPopupPosition(500, 300);
        messagePanel.setWidget(new HTML(getMessageHtml(title, message)));
        messagePanel.setWidth("300px");
        messagePanel.show();
    }
    
    private static native String getMessageHtml(String title, String message) /*-{
    return ['<div class="msg">',
            '<div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>',
            '<div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"><h3>', title, '</h3>', message, '</div></div></div>',
            '<div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>',
            '</div>'].join('');
}-*/;
}
